﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using NTTDATA.BEENChina.ResultCertification.Client.Entry.Model;
using NTTDATA.BEENChina.ResultCertification.Client.Entry.Logic;
using NTTDATA.BEENChina.ResultCertification.Client.Entry.UI;

namespace Ntt.NttData.Been.DeliveryCheck.UIEntry.UI
{
    class KeyBoardMessageFilter : IMessageFilter
    {
        private const   int   WM_KEYDOWN=0x100;   
		private const   int   VK_F1=0x70;
		private const   int   VK_F2=0x71;
		private const   int  VK_F3=0x72;
		private const   int  VK_F4=0x73;
		private const   int  VK_F5=0x74; 
		private const   int  VK_Enter=13;
        private const int VK_F8 = 0x77;
        private DeliveryEntry _deliveryEntry;

	    public KeyBoardMessageFilter(DeliveryEntry objD)
		{
            this._deliveryEntry = objD;
		}
        public bool PreFilterMessage(ref   Message m)
        {
            if (m.Msg == WM_KEYDOWN)
            {
                try
                {
                    if (DeliveryEntry.ActiveForm is DeliveryEntry)
                    {
                        if ((int)m.WParam == VK_F1)
                        {
                            DeliveryEntry.SetUICtrlStatusDel del = new DeliveryEntry.SetUICtrlStatusDel(this._deliveryEntry.JudgeUpdate);
                            del(Judge.F1);
                            return true;
                        }
                        else if ((int)m.WParam == VK_F2)
                        {
                            DeliveryEntry.SetUICtrlStatusDel del = new DeliveryEntry.SetUICtrlStatusDel(this._deliveryEntry.JudgeUpdate);
                            del(Judge.F2);
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
                catch
                {
                    return false;
                }

            }
            return false;
        }
    }
}
